home *** CD-ROM | disk | FTP | other *** search
- unit Setupu;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, ExtCtrls, Buttons;
-
- type
- TPointList = class(TComponent)
- protected
- {$ifdef Windows}
- procedure WriteComponents(Writer: TWriter); override;
- {$else}
- procedure GetChildren(Proc: TGetChildProc); override;
- {$endif}
- end;
-
- TPointData = class(TComponent)
- private
- FX, FY: Word;
- {$ifdef Windows}
- protected
- function HasParent: Boolean; override;
- {$endif}
- public
- constructor CreateXY(AOwner: TComponent; AX, AY: Word);
- procedure SwapXY;
- published
- property X: Word read FX write FX default 0;
- property Y: Word read FY write FY default 0;
- end;
-
- TForm1 = class(TForm)
- procedure FormCreate(Sender: TObject);
- private
- PointList: TPointList;
- procedure Loaded; override;
- end;
-
- var
- Form1: TForm1;
- Pt: TPointData;
-
- const
- {$ifdef Windows}
- ResFile = 'Points.R16';
- {$else}
- ResFile = 'Points.R32';
- {$endif}
-
- implementation
-
- {$R *.DFM}
-
- {$ifdef Windows}
- procedure TPointList.WriteComponents(Writer: TWriter);
- var
- Loop: Integer;
- begin
- { inherited version does nothing - no need to call it }
- for Loop := 0 to ComponentCount - 1 do
- Writer.WriteComponent(Components[Loop]);
- end;
- {$else}
- procedure TPointList.GetChildren(Proc: TGetChildProc);
- var
- Loop: Integer;
- begin
- { inherited version does nothing - no need to call it }
- for Loop := 0 to ComponentCount - 1 do
- Proc(Components[Loop]);
- end;
- {$endif}
-
- constructor TPointData.CreateXY(AOwner: TComponent; AX, AY: Word);
- begin
- inherited Create(AOwner);
- FX := AX;
- FY := AY;
- end;
-
- {$ifdef Windows}
- function TPointData.HasParent: Boolean;
- begin
- Result := True;
- end;
- {$endif}
-
- procedure TPointData.SwapXY;
- begin
- Tag := FX;
- FX := FY;
- FY := Tag;
- end;
-
- procedure TForm1.Loaded;
- begin
- inherited Loaded;
- PointList := TPointList.Create(Self);
- Pt := TPointData.CreateXY(PointList, 10, 10);
- Pt := TPointData.CreateXY(PointList, 366, 10);
- Pt := TPointData.CreateXY(PointList, 366, 191);
- Pt := TPointData.CreateXY(PointList, 10, 191);
- Pt := TPointData.CreateXY(PointList, 10, 10);
- WriteComponentResFile(ResFile, PointList);
- MessageDlg('Job done!', mtInformation, [mbOk], 0);
- Application.Terminate;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- {$ifdef Win32}
- Application.ForceMainFormVisible := False;
- {$endif}
- end;
-
- end.
-